﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdTimeStamp : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdTimeStamp(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdTimeStamp obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdTimeStamp()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdTimeStamp(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public OdTimeStamp() : this(GlobalsPINVOKE.new_OdTimeStamp__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdTimeStamp(OdTimeStamp.InitialValue init) : this(GlobalsPINVOKE.new_OdTimeStamp__SWIG_1((int)init), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getDate(out short month, out short day, out short year)
		{
			GlobalsPINVOKE.OdTimeStamp_getDate(this.swigCPtr, out month, out day, out year);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setDate(short month, short day, short year)
		{
			GlobalsPINVOKE.OdTimeStamp_setDate(this.swigCPtr, month, day, year);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short month()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_month(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setMonth(short month)
		{
			GlobalsPINVOKE.OdTimeStamp_setMonth(this.swigCPtr, month);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short day()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_day(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDay(short day)
		{
			GlobalsPINVOKE.OdTimeStamp_setDay(this.swigCPtr, day);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short year()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_year(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setYear(short year)
		{
			GlobalsPINVOKE.OdTimeStamp_setYear(this.swigCPtr, year);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getTime(out short hour, out short minute, out short second, out short millisecond)
		{
			GlobalsPINVOKE.OdTimeStamp_getTime(this.swigCPtr, out hour, out minute, out second, out millisecond);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setTime(short hour, short minute, short second, short millisecond)
		{
			GlobalsPINVOKE.OdTimeStamp_setTime(this.swigCPtr, hour, minute, second, millisecond);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short hour()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_hour(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setHour(short hour)
		{
			GlobalsPINVOKE.OdTimeStamp_setHour(this.swigCPtr, hour);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short minute()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_minute(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setMinute(short minute)
		{
			GlobalsPINVOKE.OdTimeStamp_setMinute(this.swigCPtr, minute);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short second()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_second(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setSecond(short second)
		{
			GlobalsPINVOKE.OdTimeStamp_setSecond(this.swigCPtr, second);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short millisecond()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_millisecond(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setMillisecond(short millisecond)
		{
			GlobalsPINVOKE.OdTimeStamp_setMillisecond(this.swigCPtr, millisecond);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setToZero()
		{
			GlobalsPINVOKE.OdTimeStamp_setToZero(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getLocalTime()
		{
			GlobalsPINVOKE.OdTimeStamp_getLocalTime(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getUniversalTime()
		{
			GlobalsPINVOKE.OdTimeStamp_getUniversalTime(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void localToUniversal()
		{
			GlobalsPINVOKE.OdTimeStamp_localToUniversal(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void universalToLocal()
		{
			GlobalsPINVOKE.OdTimeStamp_universalToLocal(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public uint julianDay()
		{
			uint result = GlobalsPINVOKE.OdTimeStamp_julianDay(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setJulianDay(uint julianDay)
		{
			GlobalsPINVOKE.OdTimeStamp_setJulianDay(this.swigCPtr, julianDay);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public uint msecsPastMidnight()
		{
			uint result = GlobalsPINVOKE.OdTimeStamp_msecsPastMidnight(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setMsecsPastMidnight(uint msecsPastMidnight)
		{
			GlobalsPINVOKE.OdTimeStamp_setMsecsPastMidnight(this.swigCPtr, msecsPastMidnight);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setJulianDate(uint julianDay, uint msecsPastMidnight)
		{
			GlobalsPINVOKE.OdTimeStamp_setJulianDate(this.swigCPtr, julianDay, msecsPastMidnight);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public double julianFraction()
		{
			double result = GlobalsPINVOKE.OdTimeStamp_julianFraction(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setJulianFraction(double julianFraction)
		{
			GlobalsPINVOKE.OdTimeStamp_setJulianFraction(this.swigCPtr, julianFraction);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool IsEqual(OdTimeStamp tStamp)
		{
			bool result = GlobalsPINVOKE.OdTimeStamp_IsEqual(this.swigCPtr, OdTimeStamp.getCPtr(tStamp));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsNotEqual(OdTimeStamp tStamp)
		{
			bool result = GlobalsPINVOKE.OdTimeStamp_IsNotEqual(this.swigCPtr, OdTimeStamp.getCPtr(tStamp));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdTimeStamp Add(OdTimeStamp tStamp)
		{
			OdTimeStamp result = new OdTimeStamp(GlobalsPINVOKE.OdTimeStamp_Add__SWIG_0(this.swigCPtr, OdTimeStamp.getCPtr(tStamp)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdTimeStamp Sub(OdTimeStamp tStamp)
		{
			OdTimeStamp result = new OdTimeStamp(GlobalsPINVOKE.OdTimeStamp_Sub__SWIG_0(this.swigCPtr, OdTimeStamp.getCPtr(tStamp)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdTimeStamp add(OdTimeStamp tStamp)
		{
			OdTimeStamp result = new OdTimeStamp(GlobalsPINVOKE.OdTimeStamp_add(this.swigCPtr, OdTimeStamp.getCPtr(tStamp)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdTimeStamp subtract(OdTimeStamp tStamp)
		{
			OdTimeStamp result = new OdTimeStamp(GlobalsPINVOKE.OdTimeStamp_subtract(this.swigCPtr, OdTimeStamp.getCPtr(tStamp)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void ctime(ref string timeString)
		{
			IntPtr intPtr = Marshal.StringToCoTaskMemUni(timeString);
			IntPtr value = intPtr;
			try
			{
				GlobalsPINVOKE.OdTimeStamp_ctime(this.swigCPtr, ref intPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
			finally
			{
				if (intPtr != value)
				{
					timeString = Marshal.PtrToStringUni(intPtr);
				}
			}
		}

		public void strftime(string format, ref string timeString)
		{
			IntPtr intPtr = Marshal.StringToCoTaskMemUni(timeString);
			IntPtr value = intPtr;
			try
			{
				GlobalsPINVOKE.OdTimeStamp_strftime(this.swigCPtr, format, ref intPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
			finally
			{
				if (intPtr != value)
				{
					timeString = Marshal.PtrToStringUni(intPtr);
				}
			}
		}

		public long packedValue()
		{
			long result = GlobalsPINVOKE.OdTimeStamp_packedValue(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setPackedValue(long t)
		{
			GlobalsPINVOKE.OdTimeStamp_setPackedValue(this.swigCPtr, t);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public short weekday()
		{
			short result = GlobalsPINVOKE.OdTimeStamp_weekday(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		public enum InitialValue
		{
			kInitZero = 1,
			kInitLocalTime,
			kInitUniversalTime
		}
	}
}
